using ChuTiJingTai.Models;

namespace ChuTiJingTai.Services
{
    /// <summary>
    /// 试卷生成服务接口
    /// </summary>
    public interface IExamService
    {
        /// <summary>
        /// 生成试卷
        /// </summary>
        Task<ExamPaper> GenerateExamAsync(ExamGenerationRequest request);
        
        /// <summary>
        /// 批改答卷
        /// </summary>
        Task<ExamResult> CorrectExamAsync(ExamPaper paper, string answers);
        
        /// <summary>
        /// 获取试卷列表
        /// </summary>
        Task<List<ExamPaper>> GetExamsAsync(int? childId = null);
        
        /// <summary>
        /// 删除试卷
        /// </summary>
        Task<bool> DeleteExamAsync(int examId);
    }

    /// <summary>
    /// 试卷生成请求
    /// </summary>
    public class ExamGenerationRequest
    {
        /// <summary>
        /// 孩子ID
        /// </summary>
        public int ChildId { get; set; }
        
        /// <summary>
        /// 试卷类型
        /// </summary>
        public string ExamType { get; set; } = string.Empty;
        
        /// <summary>
        /// 难度等级
        /// </summary>
        public string Difficulty { get; set; } = "标准";
        
        /// <summary>
        /// 题目数量
        /// </summary>
        public int QuestionCount { get; set; } = 10;
        
        /// <summary>
        /// 自定义要求
        /// </summary>
        public string? CustomRequirement { get; set; }
    }

    /// <summary>
    /// 试卷批改结果
    /// </summary>
    public class ExamResult
    {
        /// <summary>
        /// 试卷ID
        /// </summary>
        public int ExamId { get; set; }
        
        /// <summary>
        /// 总分
        /// </summary>
        public int TotalScore { get; set; }
        
        /// <summary>
        /// 得分
        /// </summary>
        public int Score { get; set; }
        
        /// <summary>
        /// 正确率
        /// </summary>
        public double AccuracyRate => TotalScore > 0 ? (double)Score / TotalScore : 0;
        
        /// <summary>
        /// 题目批改结果
        /// </summary>
        public List<QuestionResult> QuestionResults { get; set; } = new();
        
        /// <summary>
        /// 批改时间
        /// </summary>
        public DateTime CorrectTime { get; set; } = DateTime.Now;
        
        /// <summary>
        /// 错题分析
        /// </summary>
        public string? Analysis { get; set; }
    }

    /// <summary>
    /// 题目批改结果
    /// </summary>
    public class QuestionResult
    {
        /// <summary>
        /// 题目ID
        /// </summary>
        public string QuestionId { get; set; } = string.Empty;
        
        /// <summary>
        /// 学生答案
        /// </summary>
        public string StudentAnswer { get; set; } = string.Empty;
        
        /// <summary>
        /// 正确答案
        /// </summary>
        public string CorrectAnswer { get; set; } = string.Empty;
        
        /// <summary>
        /// 是否正确
        /// </summary>
        public bool IsCorrect { get; set; }
        
        /// <summary>
        /// 得分
        /// </summary>
        public int Score { get; set; }
        
        /// <summary>
        /// 批改说明
        /// </summary>
        public string? Comment { get; set; }
    }
} 